package com.hjq.base.http.cookie

import okhttp3.Cookie
import okhttp3.CookieJar
import okhttp3.HttpUrl

class CookieJarImpl(private var cookieStore: CookieStore) : CookieJar {

    @Synchronized
    override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
        cookieStore.add(url, cookies)
    }

    @Synchronized
    override fun loadForRequest(url: HttpUrl): List<Cookie?>? {
        return cookieStore[url]
    }

    fun getCookieStore(): CookieStore {
        return cookieStore
    }

}